﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace DQYT.HTDZ.Model
{
    /// <summary>
    /// 采集数据
    /// 保存到数据库之前需要使用 BinarySerializer.SerializeObject 方法序列化，并把结果保存到 BDDATESOURCEMODEL.CJSJ 字段
    /// 提取数据时，将 BDDATESOURCEMODEL.CJSJ 使用 BinarySerializer.DeserializeObject 方法反序列化，并把结果保存到 CJSJModel 实例
    /// </summary>
    [Serializable]
    public class CJSJModel
    {
        private float? _ayggl;
        private float? _byggl;
        private float? _cyggl;
        private float? _hyggl;
        private float? _awggl;
        private float? _bwggl;
        private float? _cwggl;
        private float? _hwggl;
        private float? _ady;
        private float? _bdy;
        private float? _cdy;
        private float? _hdy;
        private float? _adl;
        private float? _bdl;
        private float? _cdl;
        private float? _hdl;
        private float? _aglys;
        private float? _bglys;
        private float? _cglys;
        private float? _hglys;
        private float? _aszgl;
        private float? _bszgl;
        private float? _cszgl;
        private float? _hszgl;
        private float? _djscnj;
        private float? _djsczs;
        private float? _djxl;
        private float? _jsjscnn;
        private float? _qbzj;
        private float? _ltwy;
        private float? _xdzh;
        private float? _yy;
        private float? _ty;
        private float? _ymgd;
        private float? _wd;
        private float? _ygnht;
        private float? _ygnhw;
        private float? _ygnh;
        private float? _wgnht;
        private float? _wgnhw;
        private float? _wgnh;
        /// <summary>
        /// A相有功功率
        /// </summary>
        public float? AYGGL
        {
            get;
            set;
        }

        /// <summary>
        /// B相有功功率
        /// </summary>
        public float? BYGGL
        {
            get;
            set;
        }

        /// <summary>
        /// C相有功功率
        /// </summary>
        public float? CYGGL
        {
            get;
            set;
        }

        /// <summary>
        /// 合相有功功率
        /// </summary>
        public float? HYGGL
        {
            get;
            set;
        }

        /// <summary>
        /// A相无功功率
        /// </summary>
        public float? AWGGL
        {
            get;
            set;
        }

        /// <summary>
        /// B相无功功率
        /// </summary>
        public float? BWGGL
        {
            get;
            set;
        }

        /// <summary>
        /// C相无功功率
        /// </summary>
        public float? CWGGL
        {
            get;
            set;
        }

        /// <summary>
        /// 合相无功功率
        /// </summary>
        public float? HWGGL
        {
            get;
            set;
        }

        /// <summary>
        /// A相电压
        /// </summary>
        public float? ADY
        {
            get;
            set;
        }

        /// <summary>
        /// B相电压
        /// </summary>
        public float? BDY
        {
            get;
            set;
        }

        /// <summary>
        /// C相电压
        /// </summary>
        public float? CDY
        {
            get;
            set;
        }

        /// <summary>
        /// 合相电压
        /// </summary>
        public float? HDY
        {
            get;
            set;
        }

        /// <summary>
        /// A相电流
        /// </summary>
        public float? ADL
        {
            get;
            set;
        }

        /// <summary>
        /// B相电流
        /// </summary>
        public float? BDL
        {
            get;
            set;
        }

        /// <summary>
        /// C相电流
        /// </summary>
        public float? CDL
        {
            get;
            set;
        }

        /// <summary>
        /// 合相电流
        /// </summary>
        public float? HDL
        {
            get;
            set;
        }

        /// <summary>
        /// A相功率因素
        /// </summary>
        public float? AGLYS
        {
            get;
            set;
        }

        /// <summary>
        /// B相功率因素
        /// </summary>
        public float? BGLYS
        {
            get;
            set;
        }

        /// <summary>
        /// C相功率因素
        /// </summary>
        public float? CGLYS
        {
            get;
            set;
        }

        /// <summary>
        /// 合相功率因素
        /// </summary>
        public float? HGLYS
        {
            get;
            set;
        }

        /// <summary>
        /// A相视在功率
        /// </summary>
        public float? ASZGL
        {
            get;
            set;
        }

        /// <summary>
        /// B相视在功率
        /// </summary>
        public float? BSZGL
        {
            get;
            set;
        }

        /// <summary>
        /// C相视在功率
        /// </summary>
        public float? CSZGL
        {
            get;
            set;
        }

        /// <summary>
        /// 和相视在功率
        /// </summary>
        public float? HSZGL
        {
            get;
            set;
        }

        /// <summary>
        /// 电机输出扭矩
        /// </summary>
        public float? DJSCNJ
        {
            get;
            set;
        }

        /// <summary>
        /// 电机输出转速
        /// </summary>
        public float? DJSCZS
        {
            get;
            set;
        }

        /// <summary>
        /// 电机效率
        /// </summary>
        public float? DJXL
        {
            get;
            set;
        }

        /// <summary>
        /// 减速机输出扭矩
        /// </summary>
        public float? JSJSCNJ
        {
            get;
            set;
        }

        /// <summary>
        /// 曲柄转角
        /// </summary>
        public float? QBZJ
        {
            get;
            set;
        }

        /// <summary>
        /// 驴头位移
        /// </summary>
        public float? LTWY
        {
            get;
            set;
        }

        /// <summary>
        /// 悬点载荷
        /// </summary>
        public float? XDZH
        {
            get;
            set;
        }

        /// <summary>
        /// 油压
        /// </summary>
        public float? YY
        {
            get;
            set;
        }

        /// <summary>
        /// 套压
        /// </summary>
        public float? TY
        {
            get;
            set;
        }
        /// <summary>
        /// 温度
        /// </summary>
        public float? WD
        {
            get;
            set;
        }
        /// <summary>
        /// 液面高度
        /// </summary>
        public float? YMGD
        {
            get;
            set;
        }
        /// <summary>
        /// 有功能耗头
        /// </summary>
        public float? YGNHT
        {
            get;
            set;
        }
        /// <summary>
        /// 有功能耗尾
        /// </summary>
        public float? YGNHW
        {
            get;
            set;
        }
        /// <summary>
        /// 有功能耗
        /// </summary>
        public float? YGNH
        {
            get;
            set;
        }
        /// <summary>
        /// 无功能耗头
        /// </summary>
        public float? WGNHT
        {
            get;
            set;
        }
        /// <summary>
        /// 无功能耗尾
        /// </summary>
        public float? WGNHW
        {
            get;
            set;
        }
        /// <summary>
        /// 无功能耗
        /// </summary>
        public float? WGNH
        {
            get;
            set;
        }
        /// <summary>
        /// 频率
        /// </summary>
        public float? PL
        {
            get;
            set;
        }
        /// <summary>
        /// 通过一个属性的名字，给这个类中的这个属性赋值
        /// </summary>
        /// <param name="nodes"></param>
        public void SetPropertyValue(List<SJCJTextBodyNode> nodes)
        {
            foreach (SJCJTextBodyNode node in nodes)
            {
                if (string.IsNullOrWhiteSpace(node.DataName))
                    continue;
                PropertyInfo property = this.GetType().GetProperty(node.DataName);
                if (property == null)
                    continue;
                Type targetType = property.PropertyType;
                if (Nullable.GetUnderlyingType(targetType) != null)
                {
                    targetType = Nullable.GetUnderlyingType(targetType);
                }
                this.GetType().GetProperty(node.DataName).SetValue(this, Convert.ChangeType(node.DataValue, targetType), null);
            }
        }

    }
}
